<?php
/**
 * Created by PhpStorm.
 * User: LENOVO
 * Date: 2018/9/15
 * Time: 22:52
 */

namespace app\wx\controller;


use app\wx\model\History;
use app\wx\model\XcxUserInfo;

class LookHistory
{
    public function addHistory()
    {
        $data = request()->param();
        $historyModel = new History();
        $findResult = $historyModel->where('lookHouseid', $data['lookHouseid'])->find();
        if (!$findResult) {
            $historyModel->save($data);
        } else {
            $findResult->save($data);
        }
        return json([
            'code' => 0,
            'message' => 'ok'
        ]);
    }

    public function getHistory()
    {
        $userId = input('userId');
        $result = XcxUserInfo::getBuyUserId($userId);
        if ($result) {
            return json([
                'code' => 0,
                'data' => $result
            ]);
        }
    }
}